<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>数据上报</title>
	<#include "/common/resource.ftl">
	<script type="text/javascript" src="${params.contextPath}/common/My97DatePicker/WdatePicker.js"></script>
	<style>
	.layui-form-label{width: 100px;}
	.layui-input-block{margin-left: 130px;}
	</style>
</head>
<body>
<div class="ui-form" style="padding: 20px;padding-top: 10px;">
    <form class="layui-form ajax-form" action="${params.contextPath}/web/report/save.json" method="post">
        <input type="hidden" name="taskActorId" value="${params.id}"/>
        <input type="hidden" name="id" value=""/>
        <div class="layui-form-item" style="padding-top: 10px;text-align: center;" id="submitBtn">
            <input type="submit" value="保 存" class="layui-btn"/>
        </div>
    </form>
</div>
<div class="layui-form-item" id="inputTemplate" style="display: none;">
    <label class="layui-form-label">{chName}{required}</label>
    <div class="layui-input-block">
        <input type="text" class="layui-input" placeholder="{validStr}" name="{enName}" validRule="{validRule}">
    </div>
</div>
 <script type="text/javascript">
        $(function () {
        	$.ajax({
        		url:'${params.contextPath}/web/taskActor/query.json',
        		data:{id:'${params.id}'},
        		type:'GET',
        		success:function(resp){
        			var inputList = resp.data.inputList;
		           	for(var i=0;i<inputList.length;i++){
		           		var input = inputList[i];
		           		var required = '<span class="ui-request">*</span>';
		           		var validStr = "";
		           		if(input.validRule=="not_null"){
		           			validStr = '必填';
		           		}else if(input.validRule=="integer"){
		           			validStr = '整数数字';
		           		}else if(input.validRule=="number"){
		           			validStr = '数值，允许带小数点';
		           		}
		           		input.required= required;
		           		input.validStr= validStr;
		           		var formItem = $("#inputTemplate").clone();
		           		formItem.attr("id","").show();
		           		var formItemContent = formItem.html();
		           		formItemContent = formItemContent.format(input);
		           		formItem.empty().html(formItemContent);
		           		$("#submitBtn").before(formItem);
		           	}
		           	var report = resp.data.report;
                    if(report&&report.data&&report.data.json){
                        $("input[name='id']").val(report.id);
                        for(var key in report.data.json){
                            $("input[name='"+key+"']").val(report.data.json[key]);
                        }
                    }
        		},
        		dataType:'json'
        	});
        	
        });
    </script>
</body>
</html>
